from django.conf import settings
from django.conf.urls.defaults import *
from tagging.views import tagged_object_list
from models import Gallery, Photo

info_dict = {
    'queryset': Photo.published_objects.filter(site = settings.SITE_ID),
    'date_field': 'pub_date',
}

gallery_dict = {
    'queryset': Gallery.on_site.all(),
    'date_field': 'pub_date',
}

urlpatterns = patterns('',
    (r'^add/$', 'clapton.apps.photos.views.add_edit_photo'),
    (r'^edit/$', 'clapton.apps.photos.views.add_edit_photo'),
    (r'tag/(?P<tag>[^/]+(?u))/$', tagged_object_list,
     dict(model = Photo, paginate_by = 10, allow_empty = True)),
    
    # Photos
    (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[-\w]+)/$',
     'django.views.generic.date_based.object_detail', 
     dict (info_dict, slug_field = 'slug')),
    (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 
     'django.views.generic.date_based.archive_day', info_dict),
    (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 'django.views.generic.date_based.archive_month', 
     info_dict),
    (r'^(?P<year>\d{4})/$', 'django.views.generic.date_based.archive_year', info_dict),
    (r'^today/$', 'django.views.generic.date_based.archive_today', info_dict),	
    (r'^/?$', 'django.views.generic.date_based.archive_index', info_dict),
    
    # Galleries
    (r'^galleries/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[-\w]+)/$',
     'django.views.generic.date_based.object_detail', 
     dict (gallery_dict, slug_field = 'slug')),
    (r'^galleries/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 
     'django.views.generic.date_based.archive_day', gallery_dict),
    (r'^galleries/(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 'django.views.generic.date_based.archive_month', 
     gallery_dict),
    (r'^galleries/(?P<year>\d{4})/$', 'django.views.generic.date_based.archive_year', gallery_dict),
    (r'^galleries/today/$', 'django.views.generic.date_based.archive_today', gallery_dict),	
    (r'^galleries/?$', 'django.views.generic.date_based.archive_index', gallery_dict),   
)
